<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: PhyLayerBattery Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00174.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-types">Protected Types</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">PhyLayerBattery Class Reference<div class="ingroups"><a class="el" href="a00530.html">Power consumption - Classes using/defining power consumption</a> &#124; <a class="el" href="a00510.html">phyLayer - physical layer modules</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="PhyLayerBattery" --><!-- doxytag: inherits="PhyLayer" -->
<p>Extends <a class="el" href="a00173.html" title="Provides initialisation for several AnalogueModels and Deciders from modules directory.">PhyLayer</a> by adding power consumption for tx, rx and idle.  
 <a href="a00174.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00476_source.html">PhyLayerBattery.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for PhyLayerBattery:</div>
<div class="dyncontent">
<div class="center"><img src="a00933.png" border="0" usemap="#PhyLayerBattery_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for PhyLayerBattery:</div>
<div class="dyncontent">
<div class="center"><img src="a00934.png" border="0" usemap="#PhyLayerBattery_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00935.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aeee5b98e239ce3ccae9f5e20f5493a33"></a><!-- doxytag: member="PhyLayerBattery::macpkt_ptr_t" ref="aeee5b98e239ce3ccae9f5e20f5493a33" args="" -->
typedef MacPkt *&#160;</td><td class="memItemRight" valign="bottom"><b>macpkt_ptr_t</b></td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#a815f95ad9fe89412ff3c5991ec1cfafe">initialize</a> (int stage)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">OMNeT++ initialization function.  <a href="#a815f95ad9fe89412ff3c5991ec1cfafe"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#aaaaec355a89dc49db47a3ca1e4ffaf90">drawCurrent</a> (double amount, int activity)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Provides ability to draw power for the <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a>.  <a href="#aaaaec355a89dc49db47a3ca1e4ffaf90"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab297612cef7286db7722d19ea3a8924f"></a><!-- doxytag: member="PhyLayerBattery::setRadioState" ref="ab297612cef7286db7722d19ea3a8924f" args="(int rs)" -->
virtual simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#ab297612cef7286db7722d19ea3a8924f">setRadioState</a> (int rs)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Captures radio switches to adjust power consumption. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-types"></a>
Protected Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#a1eb13993a65f4147d7f99c936b4143c7">Activities</a> { <br/>
&#160;&#160;<b>SLEEP_ACCT</b> = 0, 
<b>RX_ACCT</b>, 
<b>TX_ACCT</b>, 
<b>SWITCHING_ACCT</b>, 
<br/>
&#160;&#160;<b>DECIDER_ACCT</b>
<br/>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines the power consuming activities (accounts) of the NIC. Should be the same as defined in the decider. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="a00070.html">Decider</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#a9e0540a943e06cb9d7ccc80853c40986">getDeciderFromName</a> (const std::string &amp;name, <a class="el" href="a00079.html#a37995e7f41efc2f95b081653ca01b482">ParameterMap</a> &amp;params)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates and returns an instance of the decider with the specified name.  <a href="#a9e0540a943e06cb9d7ccc80853c40986"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#a396a3436d9a7e9116f9c06b5158029ab">calcTXCurrentForPacket</a> (macpkt_ptr_t, <a class="el" href="a00133.html">MacToPhyControlInfo</a> *) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculates the current needed for the transmission of the passed MacPkt.  <a href="#a396a3436d9a7e9116f9c06b5158029ab"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5970101ea41f75adff064d267d4cd828"></a><!-- doxytag: member="PhyLayerBattery::setRadioCurrent" ref="a5970101ea41f75adff064d267d4cd828" args="(int rs)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#a5970101ea41f75adff064d267d4cd828">setRadioCurrent</a> (int rs)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Updates the actual current drawn for the passed state. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac729b2f04d9a037e8c58025634607f9e"></a><!-- doxytag: member="PhyLayerBattery::setSwitchingCurrent" ref="ac729b2f04d9a037e8c58025634607f9e" args="(int from, int to)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#ac729b2f04d9a037e8c58025634607f9e">setSwitchingCurrent</a> (int from, int to)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Updates the actual current drawn for switching between the passed states. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#a73a5457ba5a50d2d061a4cbf7dbd96b3">handleUpperMessage</a> (cMessage *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks the hosts state and draws txCurrent from battery.  <a href="#a73a5457ba5a50d2d061a4cbf7dbd96b3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#af6d51001d0cf3dae7826c3b809117977">handleAirFrame</a> (airframe_ptr_t frame)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if the the host state is on and prevents reception of AirFrames if not.  <a href="#af6d51001d0cf3dae7826c3b809117977"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#ab687d180a389989e036e158765fe6f29">handleHostState</a> (const <a class="el" href="a00098.html">HostState</a> &amp;state)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Captures changes in host state.  <a href="#ab687d180a389989e036e158765fe6f29"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a52320947de4dccb844bf26a18534fcf3"></a><!-- doxytag: member="PhyLayerBattery::finishRadioSwitching" ref="a52320947de4dccb844bf26a18534fcf3" args="(bool bSendCtrlMsg=true)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#a52320947de4dccb844bf26a18534fcf3">finishRadioSwitching</a> (bool bSendCtrlMsg=true)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Captures radio switches to adjust power consumption. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0100994772e797d41df4c41b4b9ad475"></a><!-- doxytag: member="PhyLayerBattery::numActivities" ref="a0100994772e797d41df4c41b4b9ad475" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00174.html#a0100994772e797d41df4c41b4b9ad475">numActivities</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of power consuming activities (accounts). <br/></td></tr>
<tr><td colspan="2"><div class="groupHeader">The different currents in mA.</div></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a15d15867a1ac057d60b8dc4a3771ce1b"></a><!-- doxytag: member="PhyLayerBattery::sleepCurrent" ref="a15d15867a1ac057d60b8dc4a3771ce1b" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>sleepCurrent</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a43b742fc7d58613cd7cd82547ae72ab6"></a><!-- doxytag: member="PhyLayerBattery::rxCurrent" ref="a43b742fc7d58613cd7cd82547ae72ab6" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>rxCurrent</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1f391ec04019beba1fc114d37ed2c7ea"></a><!-- doxytag: member="PhyLayerBattery::decodingCurrentDelta" ref="a1f391ec04019beba1fc114d37ed2c7ea" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>decodingCurrentDelta</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a99d73bba9a336c5d544628eb898f06ae"></a><!-- doxytag: member="PhyLayerBattery::txCurrent" ref="a99d73bba9a336c5d544628eb898f06ae" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>txCurrent</b></td></tr>
<tr><td colspan="2"><div class="groupHeader">The different switching state currents in mA.</div></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6c3a45f4e9353dc06ff28b70ae07e094"></a><!-- doxytag: member="PhyLayerBattery::setupRxCurrent" ref="a6c3a45f4e9353dc06ff28b70ae07e094" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>setupRxCurrent</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8250904854cf5543b7e25dfe683122b4"></a><!-- doxytag: member="PhyLayerBattery::setupTxCurrent" ref="a8250904854cf5543b7e25dfe683122b4" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>setupTxCurrent</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afd08d6a185179e7017c862a9223a7357"></a><!-- doxytag: member="PhyLayerBattery::rxTxCurrent" ref="afd08d6a185179e7017c862a9223a7357" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>rxTxCurrent</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0ecdf48416041bfb393351216ab15022"></a><!-- doxytag: member="PhyLayerBattery::txRxCurrent" ref="a0ecdf48416041bfb393351216ab15022" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>txRxCurrent</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Extends <a class="el" href="a00173.html" title="Provides initialisation for several AnalogueModels and Deciders from modules directory.">PhyLayer</a> by adding power consumption for tx, rx and idle. </p>
<p>Does two things, first before sending messages to the channel or receiving messages from the channel it checks the hosts current state. If the host is not able to send or the receive (e.g. no power) the messages are dropped.</p>
<p>Further it draws a current depending on the current radio state. For this it captures every call to "setRadioState()" and changes the current to previously set default values according to the new radios state. There are different currents for TX, RX, SLEEP and SWITCHING state. Its also possible to override "calcTXCurrentForPacket()" to calculate the current used during TX depending on the actual TX power instead of using the default value.</p>
<p>Does also provide battery access to the <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> by implementing DeciderToPhyInterfaces "drawCurrent()"-method. Using this method the <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> can define a current delta which is applied to the RX current during this radio state. This is meant to be used if the <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> wants to define different currents for "listening" and "decoding" phases in RX state.</p>
<p>Defines initialization for "Decider80211Battery". </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a396a3436d9a7e9116f9c06b5158029ab"></a><!-- doxytag: member="PhyLayerBattery::calcTXCurrentForPacket" ref="a396a3436d9a7e9116f9c06b5158029ab" args="(macpkt_ptr_t, MacToPhyControlInfo *) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual double PhyLayerBattery::calcTXCurrentForPacket </td>
          <td>(</td>
          <td class="paramtype">macpkt_ptr_t&#160;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a00133.html">MacToPhyControlInfo</a> *&#160;</td>
          <td class="paramname">&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [inline, protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Calculates the current needed for the transmission of the passed MacPkt. </p>
<p>A return value below or equal zero is ignored and the default txCurrent is used instead.</p>
<p>Sub classing modules can override this method if they don't want to use a default TX-current for every transmission but a current depending on the actual used TX power for a packet. </p>

<p>Referenced by <a class="el" href="a00174.html#a73a5457ba5a50d2d061a4cbf7dbd96b3">handleUpperMessage()</a>.</p>
<div class="fragment"><pre class="fragment">  { <span class="keywordflow">return</span> -1.0; }
</pre></div>
</div>
</div>
<a class="anchor" id="aaaaec355a89dc49db47a3ca1e4ffaf90"></a><!-- doxytag: member="PhyLayerBattery::drawCurrent" ref="aaaaec355a89dc49db47a3ca1e4ffaf90" args="(double amount, int activity)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PhyLayerBattery::drawCurrent </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>amount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>activity</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Provides ability to draw power for the <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a>. </p>
<p>Method is defined in "DeciderToPhyInterface".</p>
<p>Note: This method should only be used by the <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> to draw power. The phy layer itself should call instead its protected method <a class="el" href="a00140.html#a523efb31254a730e699983b50dbee44d" title="Draws the passed amount of current (in mA) over time from the battery on account of the passed accoun...">MiximBatteryAccess::drawCurrent()</a>! </p>

<p>Reimplemented from <a class="el" href="a00029.html#a81153199f268b4831f42b20b06959764">BasePhyLayer</a>.</p>

<p>References <a class="el" href="a00141.html#a234ab13c02b2b3ca369f9b18aace0e44">MiximRadio::getCurrentState()</a>, <a class="el" href="a00029.html#ab2a4c85442ff2436ca7fbe6c424c1b2c">BasePhyLayer::radio</a>, and <a class="el" href="a00141.html#a5d69aacb1cf6a57827f07224219fccb7a2c1aea88fe8363141c138da817461953">MiximRadio::RX</a>.</p>

<p>Referenced by <a class="el" href="a00174.html#a73a5457ba5a50d2d061a4cbf7dbd96b3">handleUpperMessage()</a>, <a class="el" href="a00174.html#a5970101ea41f75adff064d267d4cd828">setRadioCurrent()</a>, <a class="el" href="a00175.html#a43ef2c382a22da3bcf2445f855a69c6b">PhyLayerUWBIR::setRadioCurrent()</a>, <a class="el" href="a00174.html#ac729b2f04d9a037e8c58025634607f9e">setSwitchingCurrent()</a>, and <a class="el" href="a00175.html#a5fe0bd496dfa869ee2646fb0ca76b2da">PhyLayerUWBIR::setSwitchingCurrent()</a>.</p>
<div class="fragment"><pre class="fragment">                                                             {
  <span class="keywordflow">if</span>(<a class="code" href="a00029.html#ab2a4c85442ff2436ca7fbe6c424c1b2c" title="The state machine storing the current radio state (TX, RX, SLEEP).">radio</a>-&gt;<a class="code" href="a00141.html#a234ab13c02b2b3ca369f9b18aace0e44" title="Returns the state the Radio is currently in.">getCurrentState</a>() == <a class="code" href="a00141.html#a5d69aacb1cf6a57827f07224219fccb7a2c1aea88fe8363141c138da817461953" title="receiving state">MiximRadio::RX</a>) {
    <span class="keywordflow">if</span>(amount != 0.0) {
      <a class="code" href="a00174.html#aaaaec355a89dc49db47a3ca1e4ffaf90" title="Provides ability to draw power for the Decider.">MiximBatteryAccess::drawCurrent</a>(rxCurrent + amount, DECIDER_ACCT + activity);
    } <span class="keywordflow">else</span> {
      <a class="code" href="a00174.html#aaaaec355a89dc49db47a3ca1e4ffaf90" title="Provides ability to draw power for the Decider.">MiximBatteryAccess::drawCurrent</a>(rxCurrent, RX_ACCT);
    }
  } <span class="keywordflow">else</span> {
    opp_warning(<span class="stringliteral">&quot;Decider wanted to change power consumption while radio not in state RX.&quot;</span>);
  }
}
</pre></div>
</div>
</div>
<a class="anchor" id="a9e0540a943e06cb9d7ccc80853c40986"></a><!-- doxytag: member="PhyLayerBattery::getDeciderFromName" ref="a9e0540a943e06cb9d7ccc80853c40986" args="(const std::string &amp;name, ParameterMap &amp;params)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00070.html">Decider</a> * PhyLayerBattery::getDeciderFromName </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a00079.html#a37995e7f41efc2f95b081653ca01b482">ParameterMap</a> &amp;&#160;</td>
          <td class="paramname"><em>params</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Creates and returns an instance of the decider with the specified name. </p>
<p>Is able to initialize directly the following decider:</p>
<ul>
<li><a class="el" href="a00072.html" title="Extends Decider80211 by drawing power during receiving of messages.">Decider80211Battery</a></li>
<li><a class="el" href="a00073.html" title="Extends Decider80211 by multi channel support.">Decider80211MultiChannel</a> </li>
</ul>

<p>Reimplemented from <a class="el" href="a00173.html#a6f0907cd759351336c159c6e222beceb">PhyLayer</a>.</p>

<p>Reimplemented in <a class="el" href="a00175.html#a2ee15cb7866f9a8bcb2f7427229d409a">PhyLayerUWBIR</a>.</p>
<div class="fragment"><pre class="fragment">                                                                                        {
    params[<span class="stringliteral">&quot;decodingCurrentDelta&quot;</span>] = cMsgPar(<span class="stringliteral">&quot;decodingCurrentDelta&quot;</span>).setDoubleValue(decodingCurrentDelta);

  <span class="keywordflow">if</span>(name == <span class="stringliteral">&quot;Decider80211Battery&quot;</span>) {
    <span class="keywordflow">return</span> createDecider&lt;Decider80211Battery&gt;(params);
  }
  <span class="keywordflow">if</span>(name == <span class="stringliteral">&quot;Decider80211MultiChannel&quot;</span>) {
    <span class="keywordflow">return</span> createDecider&lt;Decider80211MultiChannel&gt;(params);
  }

  <span class="keywordflow">return</span> <a class="code" href="a00174.html#a9e0540a943e06cb9d7ccc80853c40986" title="Creates and returns an instance of the decider with the specified name.">PhyLayer::getDeciderFromName</a>(name, params);
}
</pre></div>
</div>
</div>
<a class="anchor" id="af6d51001d0cf3dae7826c3b809117977"></a><!-- doxytag: member="PhyLayerBattery::handleAirFrame" ref="af6d51001d0cf3dae7826c3b809117977" args="(airframe_ptr_t frame)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PhyLayerBattery::handleAirFrame </td>
          <td>(</td>
          <td class="paramtype">airframe_ptr_t&#160;</td>
          <td class="paramname"><em>frame</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Checks if the the host state is on and prevents reception of AirFrames if not. </p>
<p>Calls the base classes overriden method for normal handling. </p>

<p>Reimplemented from <a class="el" href="a00029.html#ac8e87dac89d0c0daa01a8d430be7e7b6">BasePhyLayer</a>.</p>

<p>References <a class="el" href="a00140.html#a76df8da8908d86b082817b03de36fcde">MiximBatteryAccess::battery</a>, and <a class="el" href="a00018.html#ab9afb1ddcea070ee4fdf9807521cc806">BaseBattery::getState()</a>.</p>
<div class="fragment"><pre class="fragment">                                                         {
  <span class="keywordflow">if</span> (<a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a> &amp;&amp; <a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>-&gt;<a class="code" href="a00018.html#ab9afb1ddcea070ee4fdf9807521cc806" title="Current state of the battery.">getState</a>() != HostState::ACTIVE) {
    coreEV&lt;&lt; <span class="stringliteral">&quot;host has FAILED, dropping air frame msg &quot;</span> &lt;&lt; frame-&gt;getName() &lt;&lt; endl;
    <span class="keyword">delete</span> frame;
    <span class="keywordflow">return</span>;
  }
  <a class="code" href="a00174.html#af6d51001d0cf3dae7826c3b809117977" title="Checks if the the host state is on and prevents reception of AirFrames if not.">PhyLayer::handleAirFrame</a>(frame);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ab687d180a389989e036e158765fe6f29"></a><!-- doxytag: member="PhyLayerBattery::handleHostState" ref="ab687d180a389989e036e158765fe6f29" args="(const HostState &amp;state)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PhyLayerBattery::handleHostState </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00098.html">HostState</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Captures changes in host state. </p>
<p>Note: Does not yet cancel any ongoing transmissions if the state changes to off. </p>

<p>Reimplemented from <a class="el" href="a00027.html#a44220aa650488eee8ad121f8bc599265">BaseModule</a>.</p>

<p>References <a class="el" href="a00098.html#a3167de707748fd5280fce231d6cbcf90">HostState::get()</a>, <a class="el" href="a00141.html#a234ab13c02b2b3ca369f9b18aace0e44">MiximRadio::getCurrentState()</a>, <a class="el" href="a00029.html#ab2a4c85442ff2436ca7fbe6c424c1b2c">BasePhyLayer::radio</a>, <a class="el" href="a00174.html#ab297612cef7286db7722d19ea3a8924f">setRadioState()</a>, and <a class="el" href="a00141.html#a5d69aacb1cf6a57827f07224219fccb7afd684ca0a1c84f153dec831272ccde42">MiximRadio::SLEEP</a>.</p>
<div class="fragment"><pre class="fragment">                                                            {
  <span class="keywordflow">if</span> (state.<a class="code" href="a00098.html#a3167de707748fd5280fce231d6cbcf90" title="Returns the host state.">get</a>() != HostState::ACTIVE &amp;&amp; <a class="code" href="a00029.html#ab2a4c85442ff2436ca7fbe6c424c1b2c" title="The state machine storing the current radio state (TX, RX, SLEEP).">radio</a>-&gt;<a class="code" href="a00141.html#a234ab13c02b2b3ca369f9b18aace0e44" title="Returns the state the Radio is currently in.">getCurrentState</a>() != <a class="code" href="a00141.html#a5d69aacb1cf6a57827f07224219fccb7afd684ca0a1c84f153dec831272ccde42" title="sleeping">MiximRadio::SLEEP</a>) {
    coreEV&lt;&lt; <span class="stringliteral">&quot;host is no longer in active state (maybe FAILED, SLEEP, OFF or BROKEN), force into sleep state!&quot;</span> &lt;&lt; endl;
    <a class="code" href="a00174.html#ab297612cef7286db7722d19ea3a8924f" title="Captures radio switches to adjust power consumption.">setRadioState</a>(<a class="code" href="a00141.html#a5d69aacb1cf6a57827f07224219fccb7afd684ca0a1c84f153dec831272ccde42" title="sleeping">MiximRadio::SLEEP</a>);
    <span class="comment">// it would be good to create a radioState OFF, as well</span>
  }
}
</pre></div>
</div>
</div>
<a class="anchor" id="a73a5457ba5a50d2d061a4cbf7dbd96b3"></a><!-- doxytag: member="PhyLayerBattery::handleUpperMessage" ref="a73a5457ba5a50d2d061a4cbf7dbd96b3" args="(cMessage *msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PhyLayerBattery::handleUpperMessage </td>
          <td>(</td>
          <td class="paramtype">cMessage *&#160;</td>
          <td class="paramname"><em>msg</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Checks the hosts state and draws txCurrent from battery. </p>
<p>Prevents sending of AirFrames if the hosts state is not on. Sets current power consumption for TX mode. Calls the base classes overriden method for normal handling. </p>

<p>Reimplemented from <a class="el" href="a00029.html#a17b1d469775962d23835dd5f43a639ac">BasePhyLayer</a>.</p>

<p>References <a class="el" href="a00140.html#a76df8da8908d86b082817b03de36fcde">MiximBatteryAccess::battery</a>, <a class="el" href="a00174.html#a396a3436d9a7e9116f9c06b5158029ab">calcTXCurrentForPacket()</a>, <a class="el" href="a00174.html#aaaaec355a89dc49db47a3ca1e4ffaf90">drawCurrent()</a>, and <a class="el" href="a00018.html#ab9afb1ddcea070ee4fdf9807521cc806">BaseBattery::getState()</a>.</p>
<div class="fragment"><pre class="fragment">                                                      {
  <span class="keywordflow">if</span> (<a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a> &amp;&amp; <a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>-&gt;<a class="code" href="a00018.html#ab9afb1ddcea070ee4fdf9807521cc806" title="Current state of the battery.">getState</a>() != HostState::ACTIVE) {
    coreEV&lt;&lt; <span class="stringliteral">&quot;host has FAILED, dropping msg &quot;</span> &lt;&lt; msg-&gt;getName() &lt;&lt; endl;
    <span class="keyword">delete</span> msg;
    <span class="keywordflow">return</span>;
  }

  macpkt_ptr_t pkt = <span class="keyword">static_cast&lt;</span>macpkt_ptr_t<span class="keyword">&gt;</span>(msg);
  <a class="code" href="a00133.html" title="Stores information which is needed by the physical layer when sending a MacPkt.">MacToPhyControlInfo</a>* cInfo = <span class="keyword">static_cast&lt;</span><a class="code" href="a00133.html" title="Stores information which is needed by the physical layer when sending a MacPkt.">MacToPhyControlInfo</a>*<span class="keyword">&gt;</span>(pkt-&gt;getControlInfo());

  <span class="keywordtype">double</span> current = <a class="code" href="a00174.html#a396a3436d9a7e9116f9c06b5158029ab" title="Calculates the current needed for the transmission of the passed MacPkt.">calcTXCurrentForPacket</a>(pkt, cInfo);

  <span class="keywordflow">if</span>(current &gt; 0) {
    <a class="code" href="a00174.html#aaaaec355a89dc49db47a3ca1e4ffaf90" title="Provides ability to draw power for the Decider.">MiximBatteryAccess::drawCurrent</a>(current, TX_ACCT);
  }

  <a class="code" href="a00174.html#a73a5457ba5a50d2d061a4cbf7dbd96b3" title="Checks the hosts state and draws txCurrent from battery.">PhyLayer::handleUpperMessage</a>(msg);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a815f95ad9fe89412ff3c5991ec1cfafe"></a><!-- doxytag: member="PhyLayerBattery::initialize" ref="a815f95ad9fe89412ff3c5991ec1cfafe" args="(int stage)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PhyLayerBattery::initialize </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stage</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>OMNeT++ initialization function. </p>
<p>Read simple parameters. Read and parse xml file for decider and analogue models configuration. </p>

<p>Reimplemented from <a class="el" href="a00029.html#a08704deaf03b73c8eda67cc60e670853">BasePhyLayer</a>.</p>

<p>Reimplemented in <a class="el" href="a00175.html#a0bb0cfac6ebb5459b7480bf9df337a3f">PhyLayerUWBIR</a>.</p>

<p>References <a class="el" href="a00141.html#a234ab13c02b2b3ca369f9b18aace0e44">MiximRadio::getCurrentState()</a>, <a class="el" href="a00053.html#ab62c70bb62f89d8d986db102228b63b7">ConnectionManagerAccess::getNic()</a>, <a class="el" href="a00174.html#a0100994772e797d41df4c41b4b9ad475">numActivities</a>, <a class="el" href="a00029.html#ab2a4c85442ff2436ca7fbe6c424c1b2c">BasePhyLayer::radio</a>, <a class="el" href="a00140.html#a18d72d9f422e37b173dad102b1e6b8a8">MiximBatteryAccess::registerWithBattery()</a>, and <a class="el" href="a00174.html#a5970101ea41f75adff064d267d4cd828">setRadioCurrent()</a>.</p>
<div class="fragment"><pre class="fragment">                                          {
  <a class="code" href="a00174.html#a815f95ad9fe89412ff3c5991ec1cfafe" title="OMNeT++ initialization function.">PhyLayer::initialize</a>(stage);
  <span class="keywordflow">if</span> (stage == 0) {
    cModule *<span class="keyword">const</span> pNic = <a class="code" href="a00053.html#ab62c70bb62f89d8d986db102228b63b7" title="Pointer to nic Module.">getNic</a>();

    <a class="code" href="a00174.html#a0100994772e797d41df4c41b4b9ad475" title="Number of power consuming activities (accounts).">numActivities</a> = hasPar(<span class="stringliteral">&quot;numActivities&quot;</span>) ? par(<span class="stringliteral">&quot;numActivities&quot;</span>).longValue() : 5;

    <span class="comment">/* parameters belong to the NIC, not just phy layer</span>
<span class="comment">     *</span>
<span class="comment">     * if/when variable transmit power is supported, txCurrent</span>
<span class="comment">     * should be specified as an xml table of available transmit</span>
<span class="comment">     * power levels and corresponding txCurrent */</span>
    sleepCurrent   = rxCurrent      = decodingCurrentDelta = txCurrent   = 0;
    setupRxCurrent = setupTxCurrent = rxTxCurrent          = txRxCurrent = 0;
    sleepCurrent         = pNic-&gt;par( <span class="stringliteral">&quot;sleepCurrent&quot;</span> );
    rxCurrent            = pNic-&gt;par( <span class="stringliteral">&quot;rxCurrent&quot;</span> );
    <span class="keywordflow">if</span> (pNic-&gt;hasPar(<span class="stringliteral">&quot;decodingCurrentDelta&quot;</span>))
        decodingCurrentDelta = pNic-&gt;par( <span class="stringliteral">&quot;decodingCurrentDelta&quot;</span> );
    txCurrent            = pNic-&gt;par( <span class="stringliteral">&quot;txCurrent&quot;</span> );
    setupRxCurrent       = pNic-&gt;par( <span class="stringliteral">&quot;setupRxCurrent&quot;</span> );
    setupTxCurrent       = pNic-&gt;par( <span class="stringliteral">&quot;setupTxCurrent&quot;</span> );
    rxTxCurrent          = pNic-&gt;par( <span class="stringliteral">&quot;rxTxCurrent&quot;</span> );
    txRxCurrent          = pNic-&gt;par( <span class="stringliteral">&quot;txRxCurrent&quot;</span> );
  } <span class="keywordflow">else</span> {
    <a class="code" href="a00140.html#a18d72d9f422e37b173dad102b1e6b8a8" title="Registers this module as a device with the battery module.">registerWithBattery</a>(<span class="stringliteral">&quot;physical layer&quot;</span>, <a class="code" href="a00174.html#a0100994772e797d41df4c41b4b9ad475" title="Number of power consuming activities (accounts).">numActivities</a>);
    <a class="code" href="a00174.html#a5970101ea41f75adff064d267d4cd828" title="Updates the actual current drawn for the passed state.">setRadioCurrent</a>(<a class="code" href="a00029.html#ab2a4c85442ff2436ca7fbe6c424c1b2c" title="The state machine storing the current radio state (TX, RX, SLEEP).">radio</a>-&gt;<a class="code" href="a00141.html#a234ab13c02b2b3ca369f9b18aace0e44" title="Returns the state the Radio is currently in.">getCurrentState</a>());
  }
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/phy/<a class="el" href="a00476_source.html">PhyLayerBattery.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/phy/PhyLayerBattery.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00174.html">PhyLayerBattery</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
